package com.xuelang.pipeline.client.pipeline;

import com.xuelang.pipeline.client.common.request.PageParam;
import com.xuelang.pipeline.client.common.result.ApiResult;
import com.xuelang.pipeline.client.common.result.PageRecord;
import com.xuelang.pipeline.client.pipeline.dto.ChangeMgmtDTO;
import com.xuelang.pipeline.client.pipeline.dto.ChangeMgmtQuery;
import org.springframework.web.bind.annotation.*;

/**
 * <p>组件变更管理Api</p>
 *
 * @author : yixin.lys
 * @date : 2024-08-02 14:29
 **/
public interface IChangeMgmtService {

    /**
     * 获取组件变更分页列表
     * @param query
     * @return
     */
    @PostMapping(value = "/page", produces = "application/json;charset=utf-8")
    ApiResult<PageRecord<ChangeMgmtDTO>> page(@RequestBody PageParam<ChangeMgmtQuery> query);

    /**
     * 新增变更
     * @param toAdd
     * @return
     */
    @PostMapping(value = "/add", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> add(@RequestBody ChangeMgmtDTO toAdd);

    /**
     * 更新现有变更
     * @param toUpdate
     * @return
     */
    @PostMapping(value = "/update", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> update(@RequestBody ChangeMgmtDTO toUpdate);

    /**
     * 根据变更id获取变更详情
     * @param id
     * @return
     */
    @GetMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResult<ChangeMgmtDTO> queryById(@PathVariable("id") String id);

    /**
     * 根据id删除变更
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> removeById(@PathVariable("id") String id);

    /**
     * 根据组件label删除变更
     * @param componentLabel
     * @return
     */
    @DeleteMapping(value = "/deleteByComponentLabel", produces = "application/json;charset=utf-8")
    ApiResult<Boolean> removeByComponentLabel(@RequestParam("label") String componentLabel);

}
